using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Configuration;
using PCSComUtils.DataAccess;
using PCSComUtils.PCSExc;
using PCSComUtils.Common;
using System.Runtime.InteropServices;
namespace PCSComMaterials.Inventory.DS
{
	public class IV_DockToStockDS 
	{
		public IV_DockToStockDS()
		{
		}
		private const string THIS = "PCSComMaterials.Inventory.DS.IV_DocToStockDS";
		private const string ACCEPTLOCATION = "AcceptLocation";
		private const string REJECTLOCATION = "RejectLocation";
		private const string REWORKMFGLOCATION = "ReworkMfgLocation";
		private const string RTVLOCATION = "RTVLocation";
		private const string RTVREWORKLOCATION = "RTVReworkLocation";
		private const string RTVREPLACELOCATION = "RTVReplaceLocation";
		private const string SCRAPLOCATION = "ScrapLocation";
		private const string USEASISLOCATION = "UseAsIsLocation";
		private const string PURSQALOCATION = "PurSQALocation";
		private const string PURNONSQALOCATION = "PurNonSQALocation";
		private const string PURNONSQAINSLOCATION = "PurNonSQAInsLocation";
		private const string PURLINEINSLOCATION = "PurLineInsLocation";
		private const string MFGSQALOCATION = "MfgSQALocation";
		private const string MFGNONSQALOCATION = "MfgNonSQALocation";
		private const string MFGNONSQAINSLOCATION = "MfgNonSQAInsInsLocation";
		private const string MFGLINEINSLOCATION = "MfgLineInsLocation";
		private const string PACKINGLOCATION = "PackingLocation";
		private const string PACKINGBIN = "PackingBin";
		
		///    <summary>
		///       This method uses to add data to IV_DocToStock
		///    </summary>
		///    <Inputs>
		///        IV_DockToStockVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Thursday, June 23, 2005
		///    </History>


		public void Add(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".Add()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				IV_DockToStockVO objObject = (IV_DockToStockVO) pobjObjectVO;
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand("", oconPCS);
				
				strSql=	"INSERT INTO IV_DocToStock("
					+ IV_DockToStockTable.ACCEPTLOCID_FLD + ","
					+ IV_DockToStockTable.REJECTLOCID_FLD + ","
					+ IV_DockToStockTable.MASTERLOCATIONID_FLD + ","
					+ IV_DockToStockTable.REWORKMFGLOCID_FLD + ","
					+ IV_DockToStockTable.RTVLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREWORKLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREPLACELOCID_FLD + ","
					+ IV_DockToStockTable.SCRAPLOCID_FLD + ","
					+ IV_DockToStockTable.USEASISLOCID_FLD + ","
					+ IV_DockToStockTable.PURSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.PURLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.PACKINGLOCID_FLD + ","
					+ IV_DockToStockTable.DOCKTOSTOCKID_FLD + ","
					+ IV_DockToStockTable.CCNID_FLD + ","
					+ IV_DockToStockTable.PACKINGBINID_FLD + ")"
					+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.ACCEPTLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.ACCEPTLOCID_FLD].Value = objObject.AcceptLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REJECTLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.REJECTLOCID_FLD].Value = objObject.RejectLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.RTVLOCID_FLD].Value = objObject.RTVLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.SCRAPLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.USEASISLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURSQALOCID_FLD].Value = objObject.PurSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQALOCID_FLD].Value = objObject.PurNonSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQAINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].Value = objObject.PurNonSQAInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURLINEINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURLINEINSLOCID_FLD].Value = objObject.PurLineInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGSQALOCID_FLD].Value = objObject.MfgSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQALOCID_FLD].Value = objObject.MfgNonSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQAINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].Value = objObject.MfgNonSQAInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGLINEINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGLINEINSLOCID_FLD].Value = objObject.MfgLineInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PACKINGLOCID_FLD].Value = objObject.PackingLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.DOCKTOSTOCKID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.DOCKTOSTOCKID_FLD].Value = objObject.DockToStockID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PACKINGBINID_FLD].Value = objObject.PackingBinID;

							
				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();
				

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	
		///    <summary>
		///       This method uses to add data to IV_DocToStock
		///    </summary>
		///    <Inputs>
		///        IV_DockToStockVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Thursday, June 23, 2005
		///    </History>

		public void Delete(int pintID)
		{
			const string METHOD_NAME = THIS + ".Delete()";
			string strSql = String.Empty;
			strSql=	"DELETE " + IV_DockToStockTable.TABLE_NAME + " WHERE  " + IV_DockToStockTable.DOCKTOSTOCKID_FLD + " = " + pintID.ToString();
			OleDbConnection oconPCS=null;
			OleDbCommand ocmdPCS =null;
			try
			{
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
				ocmdPCS = null;

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}



			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	
		///    <summary>
		///       This method uses to add data to IV_DocToStock
		///    </summary>
		///    <Inputs>
		///        IV_DockToStockVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Thursday, June 23, 2005
		///    </History>

		public object GetObjectVO(int pintID)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			DataSet dstPCS = new DataSet();
			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				strSql=	"SELECT "
					+ IV_DockToStockTable.MASTERLOCATIONID_FLD + ","
					+ IV_DockToStockTable.ACCEPTLOCID_FLD + ","
					+ IV_DockToStockTable.REJECTLOCID_FLD + ","
					+ IV_DockToStockTable.REWORKMFGLOCID_FLD + ","
					+ IV_DockToStockTable.RTVLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREWORKLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREPLACELOCID_FLD + ","
					+ IV_DockToStockTable.SCRAPLOCID_FLD + ","
					+ IV_DockToStockTable.USEASISLOCID_FLD + ","
					+ IV_DockToStockTable.PURSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.PURLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.PACKINGLOCID_FLD + ","
					+ IV_DockToStockTable.DOCKTOSTOCKID_FLD + ","
					+ IV_DockToStockTable.CCNID_FLD + ","
					+ IV_DockToStockTable.PACKINGBINID_FLD
					+ " FROM " + IV_DockToStockTable.TABLE_NAME
					+" WHERE " + IV_DockToStockTable.DOCKTOSTOCKID_FLD + "=" + pintID;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();

				IV_DockToStockVO objObject = new IV_DockToStockVO();

				while (odrPCS.Read())
				{ 
					objObject.MasterLocationID = int.Parse(odrPCS[IV_DockToStockTable.MASTERLOCATIONID_FLD].ToString().Trim());
					objObject.AcceptLocID = int.Parse(odrPCS[IV_DockToStockTable.ACCEPTLOCID_FLD].ToString().Trim());
					objObject.RejectLocID = int.Parse(odrPCS[IV_DockToStockTable.REJECTLOCID_FLD].ToString().Trim());
					objObject.ReworkMfgLocID = int.Parse(odrPCS[IV_DockToStockTable.REWORKMFGLOCID_FLD].ToString().Trim());
					objObject.RTVLocID = int.Parse(odrPCS[IV_DockToStockTable.RTVLOCID_FLD].ToString().Trim());
					objObject.RTVReworkLocID = int.Parse(odrPCS[IV_DockToStockTable.RTVREWORKLOCID_FLD].ToString().Trim());
					objObject.RTVReplaceLocID = int.Parse(odrPCS[IV_DockToStockTable.RTVREPLACELOCID_FLD].ToString().Trim());
					objObject.ScrapLocID = int.Parse(odrPCS[IV_DockToStockTable.SCRAPLOCID_FLD].ToString().Trim());
					objObject.UseAsIsLocID = int.Parse(odrPCS[IV_DockToStockTable.USEASISLOCID_FLD].ToString().Trim());
					objObject.PurSQALocID = int.Parse(odrPCS[IV_DockToStockTable.PURSQALOCID_FLD].ToString().Trim());
					objObject.PurNonSQALocID = int.Parse(odrPCS[IV_DockToStockTable.PURNONSQALOCID_FLD].ToString().Trim());
					objObject.PurNonSQAInsLocID = int.Parse(odrPCS[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].ToString().Trim());
					objObject.PurLineInsLocID = int.Parse(odrPCS[IV_DockToStockTable.PURLINEINSLOCID_FLD].ToString().Trim());
					objObject.MfgSQALocID = int.Parse(odrPCS[IV_DockToStockTable.MFGSQALOCID_FLD].ToString().Trim());
					objObject.MfgNonSQALocID = int.Parse(odrPCS[IV_DockToStockTable.MFGNONSQALOCID_FLD].ToString().Trim());
					objObject.MfgNonSQAInsLocID = int.Parse(odrPCS[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].ToString().Trim());
					objObject.MfgLineInsLocID = int.Parse(odrPCS[IV_DockToStockTable.MFGLINEINSLOCID_FLD].ToString().Trim());
					objObject.PackingLocID = int.Parse(odrPCS[IV_DockToStockTable.PACKINGLOCID_FLD].ToString().Trim());
					objObject.DockToStockID = int.Parse(odrPCS[IV_DockToStockTable.DOCKTOSTOCKID_FLD].ToString().Trim());
					objObject.CCNID = int.Parse(odrPCS[IV_DockToStockTable.CCNID_FLD].ToString().Trim());
					objObject.PackingBinID = int.Parse(odrPCS[IV_DockToStockTable.PACKINGBINID_FLD].ToString().Trim());

				}		
				return objObject;					
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		///    <summary>
		///       This method uses to add data to IV_DocToStock
		///    </summary>
		///    <Inputs>
		///        IV_DockToStockVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Thursday, June 23, 2005
		///    </History>
		
	
		public void Update(object pobjObjecVO)
		{
			const string METHOD_NAME = THIS + ".Update()";

			IV_DockToStockVO objObject = (IV_DockToStockVO) pobjObjecVO;
			

			//prepare value for parameters
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				strSql=	"UPDATE IV_DockToStock SET "
					+ IV_DockToStockTable.ACCEPTLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.REJECTLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.MASTERLOCATIONID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.REWORKMFGLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.RTVLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.RTVREWORKLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.RTVREPLACELOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.SCRAPLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.USEASISLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.PURSQALOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.PURNONSQALOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.PURLINEINSLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.MFGSQALOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.MFGNONSQALOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.PACKINGLOCID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.CCNID_FLD + "=   ?" + ","
					+ IV_DockToStockTable.PACKINGBINID_FLD + "=  ?"
					+" WHERE " + IV_DockToStockTable.DOCKTOSTOCKID_FLD + "= ?";
				/*
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.ACCEPTLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.ACCEPTLOCID_FLD].Value = objObject.AcceptLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REJECTLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.REJECTLOCID_FLD].Value = objObject.RejectLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.RTVLOCID_FLD].Value = objObject.RTVLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.SCRAPLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.USEASISLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURSQALOCID_FLD].Value = objObject.PurSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQALOCID_FLD].Value = objObject.PurNonSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQAINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].Value = objObject.PurNonSQAInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURLINEINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PURLINEINSLOCID_FLD].Value = objObject.PurLineInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGSQALOCID_FLD].Value = objObject.MfgSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQALOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQALOCID_FLD].Value = objObject.MfgNonSQALocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQAINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].Value = objObject.MfgNonSQAInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGLINEINSLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MFGLINEINSLOCID_FLD].Value = objObject.MfgLineInsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PACKINGLOCID_FLD].Value = objObject.PackingLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.PACKINGBINID_FLD].Value = objObject.PackingBinID;
				*/
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.ACCEPTLOCID_FLD, OleDbType.Integer));
				if (objObject.AcceptLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.ACCEPTLOCID_FLD].Value = objObject.AcceptLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.ACCEPTLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REJECTLOCID_FLD, OleDbType.Integer));
				if (objObject.RejectLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.REJECTLOCID_FLD].Value = objObject.RejectLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.REJECTLOCID_FLD].Value = DBNull.Value;
								
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				if (objObject.ReworkMfgLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.REWORKMFGLOCID_FLD].Value = DBNull.Value;
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVLOCID_FLD, OleDbType.Integer));
				if (objObject.RTVLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.RTVLOCID_FLD].Value = objObject.RTVLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.RTVLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				if (objObject.RTVReworkLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREWORKLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				if (objObject.RTVReplaceLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREPLACELOCID_FLD].Value = DBNull.Value;
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.SCRAPLOCID_FLD, OleDbType.Integer));
				if (objObject.ScrapLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.SCRAPLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.USEASISLOCID_FLD, OleDbType.Integer));
				if (objObject.UseAsIsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.USEASISLOCID_FLD].Value = DBNull.Value;
				
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURSQALOCID_FLD, OleDbType.Integer));
				if (objObject.PurSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURSQALOCID_FLD].Value = objObject.PurSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQALOCID_FLD, OleDbType.Integer));
				if (objObject.PurNonSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQALOCID_FLD].Value = objObject.PurNonSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQAINSLOCID_FLD, OleDbType.Integer));
				if (objObject.PurNonSQAInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].Value = objObject.PurNonSQAInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURLINEINSLOCID_FLD, OleDbType.Integer));
				if (objObject.PurLineInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURLINEINSLOCID_FLD].Value = objObject.PurLineInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURLINEINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGSQALOCID_FLD, OleDbType.Integer));
				if (objObject.MfgSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGSQALOCID_FLD].Value = objObject.MfgSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQALOCID_FLD, OleDbType.Integer));
				if (objObject.MfgNonSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQALOCID_FLD].Value = objObject.MfgNonSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQAINSLOCID_FLD, OleDbType.Integer));
				if (objObject.MfgNonSQAInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].Value = objObject.MfgNonSQAInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGLINEINSLOCID_FLD, OleDbType.Integer));
				if (objObject.MfgLineInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGLINEINSLOCID_FLD].Value = objObject.MfgLineInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGLINEINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGLOCID_FLD, OleDbType.Integer));
				if (objObject.PackingLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGLOCID_FLD].Value = objObject.PackingLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGBINID_FLD, OleDbType.Integer));
				if (objObject.PackingBinID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGBINID_FLD].Value = objObject.PackingBinID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.DOCKTOSTOCKID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.DOCKTOSTOCKID_FLD].Value = objObject.DockToStockID;
				

				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}

		///    <summary>
		///       This method uses to add data to IV_DocToStock
		///    </summary>
		///    <Inputs>
		///        IV_DockToStockVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Thursday, June 23, 2005
		///    </History>

		public DataSet List()
		{
			const string METHOD_NAME = THIS + ".List()";
			DataSet dstPCS = new DataSet();

			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				strSql=	"SELECT "
					+ IV_DockToStockTable.MASTERLOCATIONID_FLD + ","
					+ IV_DockToStockTable.ACCEPTLOCID_FLD + ","
					+ IV_DockToStockTable.REJECTLOCID_FLD + ","
					+ IV_DockToStockTable.REWORKMFGLOCID_FLD + ","
					+ IV_DockToStockTable.RTVLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREWORKLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREPLACELOCID_FLD + ","
					+ IV_DockToStockTable.SCRAPLOCID_FLD + ","
					+ IV_DockToStockTable.USEASISLOCID_FLD + ","
					+ IV_DockToStockTable.PURSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.PURLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.PACKINGLOCID_FLD + ","
					+ IV_DockToStockTable.DOCKTOSTOCKID_FLD + ","
					+ IV_DockToStockTable.CCNID_FLD + ","
					+ IV_DockToStockTable.PACKINGBINID_FLD
					+ " FROM " + IV_DockToStockTable.TABLE_NAME;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,IV_DockToStockTable.TABLE_NAME);

				return dstPCS;
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}


		}

		///    <summary>
		///       This method uses to add data to IV_DocToStock
		///    </summary>
		///    <Inputs>
		///        IV_DockToStockVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Thursday, June 23, 2005
		///    </History>
		
		public void UpdateDataSet(DataSet pdstData)
		{
			const string METHOD_NAME = THIS + ".UpdateDataSet()";
			string strSql;
			OleDbConnection oconPCS =null;
			OleDbCommandBuilder odcbPCS ;
			OleDbDataAdapter odadPCS = new OleDbDataAdapter();

			try
			{
				strSql=	"SELECT "
					+ IV_DockToStockTable.MASTERLOCATIONID_FLD + ","
					+ IV_DockToStockTable.ACCEPTLOCID_FLD + ","
					+ IV_DockToStockTable.REJECTLOCID_FLD + ","
					+ IV_DockToStockTable.REWORKMFGLOCID_FLD + ","
					+ IV_DockToStockTable.RTVLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREWORKLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREPLACELOCID_FLD + ","
					+ IV_DockToStockTable.SCRAPLOCID_FLD + ","
					+ IV_DockToStockTable.USEASISLOCID_FLD + ","
					+ IV_DockToStockTable.PURSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.PURLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.PACKINGLOCID_FLD + ","
					+ IV_DockToStockTable.DOCKTOSTOCKID_FLD + ","
					+ IV_DockToStockTable.CCNID_FLD + ","
					+ IV_DockToStockTable.PACKINGBINID_FLD 
					+ "  FROM " + IV_DockToStockTable.TABLE_NAME;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
				odcbPCS = new OleDbCommandBuilder(odadPCS);
				pdstData.EnforceConstraints = false;
				odadPCS.Update(pdstData,IV_DockToStockTable.TABLE_NAME);

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{

					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}
		/// <summary>
		/// SELECT 
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.AcceptLocID) AS AcceptLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.RejectLocID) AS RejectLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.ReworkMfgLocID) AS ReworkMfgLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.RTVLocID) AS RTVLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.RTVReworkLocID) AS RTVReworkLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.RTVReplaceLocID) AS RTVReplaceLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.ScrapLocID) AS ScrapLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.UseAsIsLocID) AS UsAsIsLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.PurSQALocID) AS PurSQALocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.PurNonSQALocID) AS PurNonSQALocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.PurNonSQAInsLocID) AS PurNonSQAInsLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.PurLineInsLocID) AS PurLineInsLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.MfgSQALocID) AS MfgSQALocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.MfgNonSQALocID) AS MfgNonSQALocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.MfgNonSQAInsLocID) AS MfgNonSQAInsInsLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.MfgLineInsLocID) AS MfgLineInsLocation,
		/// 	(SELECT Code FROM MST_Location WHERE LocationID = IV_DockToStock.PackingLocID) AS PackingLocation,
		/// 	(SELECT Code FROM MST_BIN WHERE BinID = IV_DockToStock.PackingBinID) AS PackingBin,
		/// 
		/// 	IV_DockToStock.AcceptLocID, IV_DockToStock.RejectLocID, IV_DockToStock.ReworkMfgLocID,
		/// 	IV_DockToStock.RTVLocID, IV_DockToStock.RTVReworkLocID, IV_DockToStock.RTVReplaceLocID, IV_DockToStock.ScrapLocID,
		/// 	IV_DockToStock.UseAsIsLocID, IV_DockToStock.PurSQALocID, IV_DockToStock.PurNonSQALocID, IV_DockToStock.PurNonSQAInsLocID,
		/// 	IV_DockToStock.PurLineInsLocID, IV_DockToStock.MfgSQALocID, IV_DockToStock.MfgNonSQALocID, IV_DockToStock.MfgNonSQAInsLocID,
		/// 	IV_DockToStock.MfgLineInsLocID, IV_DockToStock.PackingLocID, IV_DockToStock.PackingBinID
		/// FROM IV_DockToStock WHERE IV_DockToStock.CCNID = pintCCNID AND IV_DockToStock.MasterLocationID = pintMasterLocationID
		/// </summary>
		/// <param name="pintMasterLocationID">Master Location ID</param>
		/// <param name="pintCCNID">CCN ID</param>
		/// <returns>DataRow hold information (Code and ID) of default Location/Bin</returns>
		/// <author>Trada</author>
		/// <date>Monday, July 18 2005</date>
		
		public DataRow RetrieveData(int pintMasterLocationID, int pintCCNID)
		{
			const string METHOD_NAME = THIS + ".List()";
			DataSet dstPCS = new DataSet();
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME 
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.ACCEPTLOCID_FLD + ") AS " + ACCEPTLOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.REJECTLOCID_FLD + ") AS " + REJECTLOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.REWORKMFGLOCID_FLD + ") AS " + REWORKMFGLOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.RTVLOCID_FLD + ") AS " + RTVLOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.RTVREWORKLOCID_FLD + ") AS " + RTVREWORKLOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.RTVREPLACELOCID_FLD + ") AS " + RTVREPLACELOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.SCRAPLOCID_FLD + ") AS " + SCRAPLOCATION + ", "
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.USEASISLOCID_FLD + ") AS " + USEASISLOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURSQALOCID_FLD + ") AS " + PURSQALOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURNONSQALOCID_FLD + ") AS " + PURNONSQALOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ") AS " + PURNONSQAINSLOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURLINEINSLOCID_FLD + ") AS " + PURLINEINSLOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGSQALOCID_FLD + ") AS " + MFGSQALOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGNONSQALOCID_FLD + ") AS " + MFGNONSQALOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ") AS " + MFGNONSQAINSLOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGLINEINSLOCID_FLD + ") AS " + MFGLINEINSLOCATION + ", "	
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME
					+ " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PACKINGLOCID_FLD + ") AS " + PACKINGLOCATION + ", "	
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME
					+ " WHERE " + MST_BINTable.BINID_FLD + " = " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PACKINGBINID_FLD + ") AS " + PACKINGBIN + ", "	
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.ACCEPTLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.REJECTLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.REWORKMFGLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.RTVLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.RTVREWORKLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.RTVREPLACELOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.SCRAPLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.USEASISLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURSQALOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURNONSQALOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PURLINEINSLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGSQALOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.DOCKTOSTOCKID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGNONSQALOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MFGLINEINSLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PACKINGLOCID_FLD + ", "
					+  IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.PACKINGBINID_FLD  
					+ "	FROM " + IV_DockToStockTable.TABLE_NAME 
					+ " WHERE " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.CCNID_FLD + " = " + pintCCNID
					+ " AND " + IV_DockToStockTable.TABLE_NAME + Constants.DOT + IV_DockToStockTable.MASTERLOCATIONID_FLD + " = " + pintMasterLocationID;
				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,IV_DockToStockTable.TABLE_NAME);
				if (dstPCS.Tables[0].Rows.Count == 0)
				{
					return null;
				}
				else 
					return dstPCS.Tables[0].Rows[0];
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
		/// <summary>
		/// Insert a new record into database and return new ID
		/// </summary>
		/// <param name="pobjObjectVO">Object to insert</param>
		/// <returns>New ID</returns>
		/// <author>Trada</author>
		/// <date>Monday, July 18 2005</date>
		public int AddAndReturnID(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".AddAndReturnID()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				IV_DockToStockVO objObject = (IV_DockToStockVO) pobjObjectVO;
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand("", oconPCS);
				
				strSql=	"INSERT INTO IV_DockToStock("
					+ IV_DockToStockTable.ACCEPTLOCID_FLD + ","
					+ IV_DockToStockTable.REJECTLOCID_FLD + ","
					+ IV_DockToStockTable.MASTERLOCATIONID_FLD + ","
					+ IV_DockToStockTable.REWORKMFGLOCID_FLD + ","
					+ IV_DockToStockTable.RTVLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREWORKLOCID_FLD + ","
					+ IV_DockToStockTable.RTVREPLACELOCID_FLD + ","
					+ IV_DockToStockTable.SCRAPLOCID_FLD + ","
					+ IV_DockToStockTable.USEASISLOCID_FLD + ","
					+ IV_DockToStockTable.PURSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.PURLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQALOCID_FLD + ","
					+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ","
					+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + ","
					+ IV_DockToStockTable.PACKINGLOCID_FLD + ","
					//+ IV_DockToStockTable.DOCKTOSTOCKID_FLD + ","
					+ IV_DockToStockTable.CCNID_FLD + ","
					+ IV_DockToStockTable.PACKINGBINID_FLD + ")"
					+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.ACCEPTLOCID_FLD, OleDbType.Integer));
				if (objObject.AcceptLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.ACCEPTLOCID_FLD].Value = objObject.AcceptLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.ACCEPTLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REJECTLOCID_FLD, OleDbType.Integer));
				if (objObject.RejectLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.REJECTLOCID_FLD].Value = objObject.RejectLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.REJECTLOCID_FLD].Value = DBNull.Value;
								
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				if (objObject.ReworkMfgLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.REWORKMFGLOCID_FLD].Value = DBNull.Value;
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVLOCID_FLD, OleDbType.Integer));
				if (objObject.RTVLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.RTVLOCID_FLD].Value = objObject.RTVLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.RTVLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				if (objObject.RTVReworkLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREWORKLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				if (objObject.RTVReplaceLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.RTVREPLACELOCID_FLD].Value = DBNull.Value;
				
				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.SCRAPLOCID_FLD, OleDbType.Integer));
				if (objObject.ScrapLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.SCRAPLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.USEASISLOCID_FLD, OleDbType.Integer));
				if (objObject.UseAsIsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.USEASISLOCID_FLD].Value = DBNull.Value;
				
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURSQALOCID_FLD, OleDbType.Integer));
				if (objObject.PurSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURSQALOCID_FLD].Value = objObject.PurSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQALOCID_FLD, OleDbType.Integer));
				if (objObject.PurNonSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQALOCID_FLD].Value = objObject.PurNonSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURNONSQAINSLOCID_FLD, OleDbType.Integer));
				if (objObject.PurNonSQAInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].Value = objObject.PurNonSQAInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURNONSQAINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PURLINEINSLOCID_FLD, OleDbType.Integer));
				if (objObject.PurLineInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PURLINEINSLOCID_FLD].Value = objObject.PurLineInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PURLINEINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGSQALOCID_FLD, OleDbType.Integer));
				if (objObject.MfgSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGSQALOCID_FLD].Value = objObject.MfgSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQALOCID_FLD, OleDbType.Integer));
				if (objObject.MfgNonSQALocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQALOCID_FLD].Value = objObject.MfgNonSQALocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQALOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGNONSQAINSLOCID_FLD, OleDbType.Integer));
				if (objObject.MfgNonSQAInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].Value = objObject.MfgNonSQAInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGNONSQAINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.MFGLINEINSLOCID_FLD, OleDbType.Integer));
				if (objObject.MfgLineInsLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.MFGLINEINSLOCID_FLD].Value = objObject.MfgLineInsLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.MFGLINEINSLOCID_FLD].Value = DBNull.Value;
				

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGLOCID_FLD, OleDbType.Integer));
				if (objObject.PackingLocID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGLOCID_FLD].Value = objObject.PackingLocID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGLOCID_FLD].Value = DBNull.Value;
				

				//				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.DOCKTOSTOCKID_FLD, OleDbType.Integer));
				//				ocmdPCS.Parameters[IV_DockToStockTable.DOCKTOSTOCKID_FLD].Value = objObject.DockToStockID;
			

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_DockToStockTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_DockToStockTable.PACKINGBINID_FLD, OleDbType.Integer));
				if (objObject.PackingBinID != 0)
				{
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGBINID_FLD].Value = objObject.PackingBinID;
				}
				else 
					ocmdPCS.Parameters[IV_DockToStockTable.PACKINGBINID_FLD].Value = DBNull.Value;
				

				strSql += " ; SELECT @@IDENTITY AS NEWID";
				
				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				//ocmdPCS.ExecuteNonQuery();	
				object objReturn = ocmdPCS.ExecuteScalar();	
				if (objReturn != null)
				{
					return int.Parse(objReturn.ToString());
				}
				else
				{
					return 0;
				}

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		/// <summary>
		/// Get default information of MasterLocation
		/// </summary>
		/// <param name="pintMasLoc"></param>
		/// <returns></returns>
		public DataRow GetDockToStockForMasLoc(int pintMasLoc)
		{
			try
			{
				const string METHOD_NAME = THIS + ".GetDockToStockForMasLoc()";
				const string ALIAS_FLD = "DTS";
				DataSet dstPCS = new DataSet();

				OleDbConnection oconPCS =null;
				OleDbCommand ocmdPCS = null;
				try 
				{
					string strSql = "SELECT "
						+ IV_DockToStockTable.MASTERLOCATIONID_FLD + ","
						+ IV_DockToStockTable.ACCEPTLOCID_FLD + ","
						+ IV_DockToStockTable.REJECTLOCID_FLD + ","
						+ IV_DockToStockTable.REWORKMFGLOCID_FLD + ","
						+ IV_DockToStockTable.RTVLOCID_FLD + ","
						+ IV_DockToStockTable.RTVREWORKLOCID_FLD + ","
						+ IV_DockToStockTable.RTVREPLACELOCID_FLD + ","
						+ IV_DockToStockTable.SCRAPLOCID_FLD + ","
						+ IV_DockToStockTable.USEASISLOCID_FLD + ","
						+ IV_DockToStockTable.PURSQALOCID_FLD + ","
						+ IV_DockToStockTable.PURNONSQALOCID_FLD + ","
						+ IV_DockToStockTable.PURNONSQAINSLOCID_FLD + ","
						+ IV_DockToStockTable.PURLINEINSLOCID_FLD + ","
						+ IV_DockToStockTable.MFGSQALOCID_FLD + ","
						+ IV_DockToStockTable.MFGNONSQALOCID_FLD + ","
						+ IV_DockToStockTable.MFGNONSQAINSLOCID_FLD + ","
						+ IV_DockToStockTable.MFGLINEINSLOCID_FLD + ","
						+ IV_DockToStockTable.PACKINGLOCID_FLD + ","
						+ IV_DockToStockTable.DOCKTOSTOCKID_FLD + ","
						+ IV_DockToStockTable.CCNID_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.ACCEPTLOCID_FLD + ") as " + IV_DockToStockTable.ACCEPTLOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.REJECTLOCID_FLD + ") as " + IV_DockToStockTable.REJECTLOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.REWORKMFGLOCID_FLD + ") as " + IV_DockToStockTable.REWORKMFGLOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.RTVLOCID_FLD + ") as " + IV_DockToStockTable.RTVLOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.RTVREWORKLOCID_FLD + ") as " + IV_DockToStockTable.RTVREWORKLOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.RTVREPLACELOCID_FLD + ") as " + IV_DockToStockTable.RTVREPLACELOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.REWORKMFGLOCID_FLD + ") as " + IV_DockToStockTable.REWORKMFGLOCID_FLD + MST_LocationTable.CODE_FLD + ","
						+ "( SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.USEASISLOCID_FLD + ") as " + IV_DockToStockTable.USEASISLOCID_FLD + MST_LocationTable.CODE_FLD + ","

						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.ACCEPTLOCID_FLD + ") as " + IV_DockToStockTable.ACCEPTLOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.REJECTLOCID_FLD + ") as " + IV_DockToStockTable.REJECTLOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.REWORKMFGLOCID_FLD + ") as " + IV_DockToStockTable.REWORKMFGLOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.RTVLOCID_FLD + ") as " + IV_DockToStockTable.RTVLOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.RTVREWORKLOCID_FLD + ") as " + IV_DockToStockTable.RTVREWORKLOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.RTVREPLACELOCID_FLD + ") as " + IV_DockToStockTable.RTVREPLACELOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.REWORKMFGLOCID_FLD + ") as " + IV_DockToStockTable.REWORKMFGLOCID_FLD + MST_LocationTable.BIN_FLD + ","
						+ "( SELECT " + MST_LocationTable.BIN_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + "=" + ALIAS_FLD + "." + IV_DockToStockTable.USEASISLOCID_FLD + ") as " + IV_DockToStockTable.USEASISLOCID_FLD + MST_LocationTable.BIN_FLD + ","

						+ IV_DockToStockTable.PACKINGBINID_FLD
						+ " FROM " + IV_DockToStockTable.TABLE_NAME + " " + ALIAS_FLD
						+ " WHERE "+ IV_DockToStockTable.MASTERLOCATIONID_FLD + "=" + pintMasLoc;
					
					oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
					ocmdPCS = new OleDbCommand(strSql, oconPCS);
					ocmdPCS.Connection.Open();
				
					OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
					odadPCS.Fill(dstPCS,IV_DockToStockTable.TABLE_NAME);
					if (dstPCS.Tables[0].Rows.Count > 0)
						return dstPCS.Tables[0].Rows[0];
				}
				catch(OleDbException ex)
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}			
				catch (Exception ex) 
				{
					throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
				}

				finally 
				{
					if (oconPCS!=null) 
					{
						if (oconPCS.State != ConnectionState.Closed) 
						{
							oconPCS.Close();
						}
					}
				}	
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}
			return null;
		}
	}
}
